package com.supers.servlet.listener;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * 监听器
 * @author LC
 *
 */
public class ActionListener implements ServletContextListener{
	
	/**
	 * tomcat销毁时执行：清空application域中的所有的action的配置
	 */
	public void contextDestroyed(ServletContextEvent agr0) {
		agr0.getServletContext().setAttribute("actions", null) ;
	}

	/**
	 * tomcat初始化时执行
	 */
	public void contextInitialized(ServletContextEvent agr0) {
		/**
		 * 1、创建一个map
		 * 2、把key,value放入到map中
		 * 3、把map放入到application域中
		 */
		Map<String, String> map = new HashMap<String, String>() ;
		map.put("userAction", "com.supers.servlet.action.userAction") ;
		agr0.getServletContext().setAttribute("actions", map) ;
	}
	

}
